﻿using System;
using System.Web;
using Besture.Bll;
using Besture.Common;
using Besture.Common.Helper;
using Besture.Model;
using Besture.UI.Common;

namespace Besture.UI.Portal.UserCenter
{
    public partial class ChangePwd : UserPage
    {
        /// 修改信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SaveClick(object sender, EventArgs e)
        {
            UserNav.Selected[1] = "on";
            if (GetUserLoginModel().LoginPwd == StringHelper.GetMD5(Request["pwd"]))
            {
                var cusdac = new UserBaseDac();
                var cusmodel = new UserBaseModel();
                cusmodel = cusdac.GetModel(GetUserLoginModel().ID);
                cusmodel.LoginPwd = StringHelper.GetMD5(newpwd.Value);
                if (cusdac.Update(cusmodel) > 0)
                {
                   HttpContext.Current.Session[Constants.SESSION_WEB_USER_MODEL] = null;
                   FunHelper.Alert("修改密码成功！", "/Portal/UserCenter/Login.aspx");
                }
            }
            else
            {
               FunHelper.Alert("原密码错误！");
            }
        }
    }
}